package com.itheima.demo10_多态的好处和弊端;

class Animal {
    public void eat() {
        System.out.println("吃东西。。。。");
    }
}

class Dog extends Animal {
    int num = 10;
    @Override
    public void eat() {
        System.out.println("狗吃骨头。。。。");
    }
    //独有的成员方法
    public void lookhoom() {
        System.out.println("狗正在看家。。。。");
    }
}

public class Test {
    public static void main(String[] args) {
        Animal anl1 = new Dog();
//        System.out.println(anl1.num);
//        anl1.lookhoom();
        //        返回值多态
        Animal anl2 = method1();
        anl1.eat();

        Dog d = new Dog();
        method(d);
    }
    //    形参多态
        public static void method(Animal anl) {
            anl.eat();
        }




//    private static Animal method1(String dog) {
//    }
//        返回值多态
    public static Animal method1() {
        return new Dog();
    }


}
